package com.cskaoyan.dbutils;

import com.cskaoyan.others.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;
import java.sql.SQLException;

/**
 * 创建日期: 2021/11/25 15:19
 *
 * @author ciggar
 * 使用传入数据源的构造方法构造QueryRunner对象
 */
public class DBUtilsDemo2 {

    public static void main(String[] args) throws SQLException {

//        // 通过数据库连接池来构造
        DataSource dataSource = DruidUtils.getDataSource();
        QueryRunner queryRunner = new QueryRunner(dataSource);

        // 执行SQL语句
        int affectedRows = queryRunner.update("update account set money = ? where id = ?",2000,1);

        System.out.println("affectedRows:" + affectedRows);
    }
}
